package beans;

public class Calculator {
    private double x;
    private double y;
    private double z=0;
    private char zifu;

    public double getZ() {return z;}

    public void setZ(double z) {this.z = z;}

    public char getZifu() {return zifu;}

    public void setZifu(char zifu) {this.zifu = zifu;}

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double jisuan(){
        switch (zifu){
            case '+':
                z=x+y;
                break;
            case '-':
                z=x-y;
                break;
            case '*':
                z=x*y;
                break;
            case '/':
                if(y==0)
                    System.out.print("除数不能为0！");
                else
                    z=x/y;
                break;
        }
        return z;
    }
}
